package cn.minhx.domain.activity.service.discount.impl;

import cn.minhx.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import cn.minhx.domain.activity.service.discount.AbstractDiscountCalculator;
import com.alibaba.fastjson2.JSON;
import java.math.BigDecimal;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 直减
 *
 * @author min
 */
@Slf4j
@Service("ZJ")
public class ZJCalculator extends AbstractDiscountCalculator {

	@Override
	protected BigDecimal doCalculate(BigDecimal originalPrice,
			GroupBuyActivityDiscountVO.GroupBuyDiscount groupBuyDiscount) {
		log.info("优惠策略-直减计算 originalPrice:{} groupBuyDiscount:{}", originalPrice, JSON.toJSONString(groupBuyDiscount));
		// 折扣表达式 - 直减为扣减金额
		String marketExpr = groupBuyDiscount.getMarketExpr();
		// 折后价格
		return originalPrice.subtract(new BigDecimal(marketExpr));
	}
}
